<?php
/**
 * Created by PhpStorm.
 * User: alice
 * Date: 2016/1/14
 * Time: 11:06
 */

class Involved_ProducingAreaModel extends BaseModel{

    protected $table = 'producing_area';

    /********************************   APP接口   *****************************/

    public function GetAreaList($cate_id)
    {
        $araes = DB::table($this->table)
            ->select('area_id','area_name')
            ->where('quality',$cate_id)
            ->get();

        $info = [];
        foreach ($araes as $arae) {
            $info[] = [
                'id'    =>  $arae->area_id,
                'name'  =>  $arae->area_name,
            ];
        }

        return $info;
    }


    /********************************   PC   *****************************/


    /**
     * 产地展示
     * @return mixed
     * @author alice
     * @date 2016-1-25
     */
    public function ShowAreaList()
    {
        return DB::table($this->table)->paginate(10);
    }

    /**
     * 产地详情
     * @param $id
     * @return mixed
     */
    public function GetAreaInfo($id)
    {
        return DB::table($this->table)
                ->where('area_id',$id)
                ->first();
    }

}